﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Windows;
using System.Windows.Controls;

namespace PacketBuilder
{
    public partial class MainWindow
    {
        static void optionCheckBox_UpdateOptionsMap(object sender, RoutedEventArgs e)
        {
            var senderCheckBox = sender as CheckBox;
            if (null != senderCheckBox.IsChecked)
            {
                if (true == optionsMap.ContainsKey((string)senderCheckBox.Tag))
                {
                    optionsMap[(string)senderCheckBox.Tag] = senderCheckBox.IsChecked.ToString();
                }
                else
                {
                    optionsMap.Add((string)senderCheckBox.Tag, senderCheckBox.IsChecked.ToString());
                }
            }
        }

        static void optionTextBox_UpdateOptionsMap(object sender, TextChangedEventArgs e)
        {
            var senderControl = sender as TextBox;
            if (true == optionsMap.ContainsKey((string)senderControl.Tag))
            {
                optionsMap[(string)senderControl.Tag] = senderControl.Text;
            }
            else
            {
                optionsMap.Add((string)senderControl.Tag, senderControl.Text);
            }
        }

        static void comboBoxItem_UpdateOptionsMap(object sender, RoutedEventArgs e)
        {
            var senderComboBoxItem = sender as ComboBoxItem;
            var senderParent = senderComboBoxItem.Parent as ComboBox;

            if (true == optionsMap.ContainsKey((string)senderParent.Tag))
            {
                optionsMap[(string)senderParent.Tag] = (string)senderComboBoxItem.Content;
            }
            else
            {
                optionsMap.Add((string)senderParent.Tag, (string)senderComboBoxItem.Content);
            }            
        }
    }
}